package com.gpframework.module.controller.process;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
import java.util.Arrays;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gpframework.common.annotation.Log;
import com.gpframework.common.core.controller.BaseController;
import com.gpframework.common.core.domain.AjaxResult;
import com.gpframework.common.enums.BusinessType;
import com.gpframework.module.process.domain.GpProcessFlowerPattern;
import com.gpframework.module.process.domain.vo.GpProcessFlowerPatternVo;
import com.gpframework.module.process.domain.req.GpProcessFlowerPatternReq;
import com.gpframework.module.process.domain.req.GpProcessFlowerPatternAdd;
import com.gpframework.module.process.domain.req.GpProcessFlowerPatternUpdate;
import com.gpframework.module.process.service.IGpProcessFlowerPatternService;
import com.gpframework.common.utils.poi.ExcelUtil;
import javax.validation.Valid;
import io.swagger.annotations.*;
import com.gpframework.common.core.page.TableDataInfo;
/**
 * @ClassName GpProcessFlowerPatternController
 * @Author gpframework
 * @Date 2024-04-26
 * @Version 1.0.0
 * @Description 做货花型描述Controller
 */
@Validated
@Api(tags = "做货花型描述")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@SuppressWarnings({"rawtypes","unchecked"})
@RequestMapping("/process/gpProcessFlowerPattern" )
public class GpProcessFlowerPatternController extends BaseController {

    private final IGpProcessFlowerPatternService iGpProcessFlowerPatternService;

 /**
  * @Description 分页
  * @Author gpframework
  * @Date 2024-04-26
  * @Param gpProcessFlowerPattern
  * @Return TableDataInfo
 */
    @ApiOperation("列表")
    @PreAuthorize("@ss.hasPermi('process:gpProcessFlowerPattern:list')")
    @GetMapping("/list")
    public TableDataInfo<GpProcessFlowerPatternVo> list(GpProcessFlowerPatternReq gpProcessFlowerPatternReq)
    {
        startPage();
        QueryWrapper<GpProcessFlowerPattern> lqw = new QueryWrapper<GpProcessFlowerPattern>();
        gpProcessFlowerPatternReq.generatorQuery(lqw,true);
        List<GpProcessFlowerPatternVo> list = iGpProcessFlowerPatternService.listVo(lqw);
        return getDataTable(list);
    }

    /**
     * @Description 新增
     * @Author gpframework
     * @Date 2024-04-26
     * @Param gpProcessFlowerPattern
     * @Return TableDataInfo
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('process:gpProcessFlowerPattern:add')" )
    @Log(title = "添加做货花型描述" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody GpProcessFlowerPatternAdd gpProcessFlowerPatternAdd) {
        GpProcessFlowerPattern gpProcessFlowerPattern = Convert.convert(new TypeReference<GpProcessFlowerPattern>() {}, gpProcessFlowerPatternAdd);
        return toAjax(iGpProcessFlowerPatternService.save(gpProcessFlowerPattern) ? 1 : 0);
    }

    /**
     * @Description 修改
     * @Author gpframework
     * @Date 2024-04-26
     * @Param gpProcessFlowerPattern
     * @Return TableDataInfo
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('process:gpProcessFlowerPattern:edit')" )
    @Log(title = "修改做货花型描述" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody GpProcessFlowerPatternUpdate gpProcessFlowerPatternUpdate) {
        GpProcessFlowerPattern gpProcessFlowerPattern = Convert.convert(new TypeReference<GpProcessFlowerPattern>() {}, gpProcessFlowerPatternUpdate);
        return toAjax(iGpProcessFlowerPatternService.updateById(gpProcessFlowerPattern) ? 1 : 0);
    }


    /**
     * @Description 导出
     * @Author gpframework
     * @Date 2024-04-26
     * @Param gpProcessFlowerPattern
     * @Return TableDataInfo
     */

    @PreAuthorize("@ss.hasPermi('process:gpProcessFlowerPattern:export')" )
    @Log(title = "导出做货花型描述" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(GpProcessFlowerPatternReq gpProcessFlowerPatternReq) {
        QueryWrapper<GpProcessFlowerPattern> lqw = new QueryWrapper<GpProcessFlowerPattern>();
        gpProcessFlowerPatternReq.generatorQuery(lqw,true);
        List<GpProcessFlowerPatternVo> list = iGpProcessFlowerPatternService.listVo(lqw);
        ExcelUtil<GpProcessFlowerPatternVo> util = new ExcelUtil<GpProcessFlowerPatternVo>(GpProcessFlowerPatternVo. class);
        return util.exportExcel(list, "gpProcessFlowerPattern" );
    }

    /**
     * @Description 详情
     * @Author gpframework
     * @Date 2024-04-26
     * @Param gpProcessFlowerPattern
     * @Return TableDataInfo
     */
    @ApiOperation("详情")
    @PreAuthorize("@ss.hasPermi('process:gpProcessFlowerPattern:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult<GpProcessFlowerPatternVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iGpProcessFlowerPatternService.getVoById(id));
    }



    /**
     * @Description 删除
     * @Author gpframework
     * @Date 2024-04-26
     * @Param gpProcessFlowerPattern
     * @Return TableDataInfo
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('process:gpProcessFlowerPattern:remove')" )
    @Log(title = "删除做货花型描述" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iGpProcessFlowerPatternService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
